Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@formatjs/intl-utils

Package Overview
Dependencies
Maintainers
3
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@formatjs/intl-utils

Smartly determine best unit for relative time format

  • 3.8.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
325K
decreased by-6.08%
Maintainers
3
Weekly downloads
 
Created

What is @formatjs/intl-utils?

@formatjs/intl-utils is a utility library that provides various internationalization (i18n) utilities. It is part of the FormatJS suite and is designed to help with formatting dates, numbers, and messages in a way that is locale-aware.

What are @formatjs/intl-utils's main functionalities?

Date Formatting

This feature allows you to format dates according to the specified locale and options. The example formats the current date in the 'en-US' locale.

const { formatDate } = require('@formatjs/intl-utils');
const date = new Date();
const formattedDate = formatDate(date, { year: 'numeric', month: 'long', day: 'numeric' }, 'en-US');
console.log(formattedDate); // Output: 'October 5, 2023'

Number Formatting

This feature allows you to format numbers according to the specified locale and options. The example formats a number as a currency in the 'en-US' locale.

const { formatNumber } = require('@formatjs/intl-utils');
const number = 1234567.89;
const formattedNumber = formatNumber(number, { style: 'currency', currency: 'USD' }, 'en-US');
console.log(formattedNumber); // Output: '$1,234,567.89'

Message Formatting

This feature allows you to format messages with placeholders according to the specified locale and values. The example formats a message by replacing the placeholder with a value in the 'en-US' locale.

const { formatMessage } = require('@formatjs/intl-utils');
const message = 'Hello, {name}!';
const values = { name: 'John' };
const formattedMessage = formatMessage(message, values, 'en-US');
console.log(formattedMessage); // Output: 'Hello, John!'

Other packages similar to @formatjs/intl-utils

Keywords

FAQs

Package last updated on 17 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc